www.gusucode.com > VC 串口通讯_数据库存取例子-源码程序 > VC 串口通讯_数据库存取例子-源码程序/code/Modem3/ReshueiDialog.cpp

    //Download by http://www.NewXing.com
// ReshueiDialog.cpp : implementation file
//

#include "stdafx.h"
#include "Modem3.h"
#include "ReshueiDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CReshueiDialog dialog


CReshueiDialog::CReshueiDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CReshueiDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CReshueiDialog)
	m_down = 0.0f;
	m_up = 0.0f;
	//}}AFX_DATA_INIT
  CWnd *ppWnd=CWnd::FindWindow(NULL,"modem3");
   pWnd=((CModem3Dlg *)ppWnd);
}


void CReshueiDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CReshueiDialog)
	DDX_Text(pDX, IDC_DOWN, m_down);
	DDV_MinMaxFloat(pDX, m_down, 30.f, 70.f);
	DDX_Text(pDX, IDC_UP, m_up);
	DDV_MinMaxFloat(pDX, m_up, 40.f, 85.f);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CReshueiDialog, CDialog)
	//{{AFX_MSG_MAP(CReshueiDialog)
	ON_BN_CLICKED(IDC_YINGYONG, OnYingyong)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CReshueiDialog message handlers

void CReshueiDialog::OnYingyong() 
{
	// TODO: Add your control notification handler code here
	 int i;
	 this->UpdateData(TRUE);
	 pWnd->send_data[0]=0xf7;
	 pWnd->send_data[1]=0xf8;
	 pWnd->send_data[2]=0x12;
	 pWnd->send_data[3]=0x01;
	 pWnd->send_data[4]=yd[4];
	 pWnd->send_data[5]=0x44;
	 for(i=6;i<20;i++)
		 pWnd->send_data[i]=yd[i+1];
	 pWnd->send_data[6]=int(m_up*2);
	 pWnd->send_data[7]=int(m_down*2);
    
	 pWnd->send_data[20]=0;
	 for(i=2;i<20;i++)
		 pWnd->send_data[20]=+pWnd->send_data[i];
	 pWnd->send_data[21]=0xfd;
	 pWnd->send_flag=1;	
}

BOOL CReshueiDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	int i;
	// TODO: Add extra initialization here
	for(i=0;i<23;i++)
		yd[i]=pWnd->immediate_data[i];
     m_up=float(yd[7])/2;
	 m_down=float(yd[8])/2;
	 
	 this->UpdateData(FALSE);
     	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}